import { handleActions } from "redux-actions";
import Immutable from "seamless-immutable";
import * as type from "../types/course";
// interface CourseState {
//   currentStep: number;
//   wsid: string;
//   tableNameList: any[];
//   currentTableName: string;
//   currentTableFieldGroup: any[];
// }

export const defaultState = Immutable({
  currentStep: 0,
  wsid: "",
  tableNameList: [],
  currentTableName: "",
  currentTableFieldGroup: [],
  isBack: false
});

export default handleActions(
  {
    [type.COURSE_SET_CURRENT_STEP]: (state, action: any) =>
      state.set("currentStep", action.result),
    [type.COURSE_SET_WSID]: (state, action: any) =>
      state.set("wsid", action.result),
    [type.COURSE_SET_TABLE_NAME_LIST]: (state, action: any) =>
      state.set("tableNameList", action.result),
    [type.COURSE_SET_CURRENT_TABLE_NAME]: (state, action: any) =>
      state.set("currentTableName", action.result),
    [type.COURSE_SET_CURRENT_TABLE_FIELD_GROUP]: (state, action: any) =>
      state.set("currentTableFieldGroup", action.result),
    [type.COURSE_SET_IS_BACK]: (state, action: any) =>
      state.set("isBack", action.result)
  },
  defaultState
);
